package com.eco.utils;

import com.github.benmanes.caffeine.cache.Cache;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
/* loaded from: newfishway-1.0.0-SNAPSHOT.jar:BOOT-INF/classes/com/eco/utils/GenerateToken.class */
public class GenerateToken {
    private static final Logger log = LoggerFactory.getLogger((Class<?>) GenerateToken.class);

    @Autowired
    Cache<String, Object> caffeineCache;

    public String createToken(String keyPrefix, String cacheValue) {
        if (StringUtils.isEmpty(cacheValue)) {
            log.error("cacheValue is NULL");
        }
        String token = keyPrefix + UUID.randomUUID().toString().replace("-", "");
        this.caffeineCache.put(token, cacheValue);
        return token;
    }

    public String getToken(String token) {
        if (StringUtils.isEmpty(token)) {
            log.error("token is NULL");
            return null;
        }
        String value = (String) this.caffeineCache.getIfPresent(token);
        return value;
    }

    public void removeToken(String token) {
        if (StringUtils.isEmpty(token)) {
            log.error("token is NULL");
        } else {
            this.caffeineCache.asMap().remove(token);
        }
    }
}